<template>
  <div class="dailyRecharge">
    <h3>每日充值</h3>
    <div class="search">
      <div class="cond2 cond">
        <label>支付时间</label>
        <el-date-picker
          v-model="search1"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </div>
      <div class="cond2 cond">
        <label>支付通道</label>
        <el-select v-model="search2" placeholder="请选择">
          <el-option
            v-for="item in optionsPayType"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </div>
      <div>
        <el-button type="primary" icon="el-icon-search" @click="searchMethod">搜索</el-button>
      </div>
    </div>
    <div class="list">
      <el-table
        border
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
      >
        <el-table-column type="index" width="50" header-align="center" align="center" label="序号"></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="created_date"
          label="支付日期"
          sortable
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="pay_gate_way"
          label="支付通道"
          width="200"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="order_all"
          label="创建订单数"
          width="200"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="order_all_pay"
          label="成功订单量"
          width="200"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="real_amount_all"
          label="订单金额"
          width="200"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="real_amount_all_pay"
          label="成功金额"
          sortable
          width="200"
        ></el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="conversion"
          label="成功率%"
          sortable
          width="200"
        ></el-table-column>
      </el-table>
    </div>
    <!-- <div class="page">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage1"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="totalSize"
      ></el-pagination>
    </div>-->
  </div>
</template>
<script>
export default {
  name: "dailyRecharge",
  data() {
    return {
      optionsPayType: [],
      search1: "",
      search2: "",
      tableData: [],
      currentPage1: 1,
      pageSize: 10,
      totalSize: 0,
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      initData: {}
    };
  },
  mounted() {
    this.getInitList();
    this.getPayType();
  },
  methods: {
    // 分页
    handleCurrentChange(val) {
      this.currentPage1 = val;
      this.getInitList();
    },
    //获取统计列表
    async getInitList() {
      let parames = {
        handshake: "",
        data: {
          // page: this.currentPage1,
          // page_size: this.pageSize,
          search: {
            pay_gate_way: this.search2,
            stime: this.search1&&this.search1.length > 0 ? this.search1[0] : "",
            otime: this.search1&&this.search1.length > 1 ? this.search1[1] : ""
          }
        }
      };
      let res = await this.$axios.post(
        this.$api.orderDay_list,
        JSON.stringify(parames)
      );
      if (res.code == 200) {
        this.initData = res.data;
        // this.totalSize = this.initData.total;
        this.tableData = this.initData;
      } else {
        this.$message({
          message: res.message,
          type: "warning"
        });
      }
    },
    searchMethod() {
      this.currentPage1=1;
      this.getInitList();
    },
    //获取支付方式列表
    async getPayType() {
      let parames = {
        handshake: "",
        data: {}
      };
      let res = await this.$axios.post(
        this.$api.orderPayment_data,
        JSON.stringify(parames)
      );
      if (res.code == 200) {
        this.optionsPayType = res.data;
        this.optionsPayType.unshift({id:"",name:"全部"});
      } else {
        this.$message({
          message: res.message,
          type: "warning"
        });
      }
    }
  }
};
</script>
<style scoped>
h3 {
  padding: 0.2rem;
  color: #3c763d;
}
.search {
  display: flex;
  margin-top: 0.2rem;
  padding-left: 0.2rem;
  width: 100%;
  flex-wrap: wrap;
}
.el-input {
  width: 2.5rem;
}
label {
  width: 0.83rem;
  height: 0.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f7fa;
  color: #909399;
  border: 1px solid #dcdfe6;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
}
.cond {
  display: flex;
  margin-right: 0.4rem;
  margin-bottom: 0.1rem;
}
.search .el-select >>> .el-input__inner {
  border-left: none;
  border-top-left-radius: 0px;
  border-bottom-left-radius: 0px;
}
.search .el-select {
  width: 1.67rem;
}
.opration {
  margin-top: 0.2rem;
  padding-left: 0.2rem;
}
.page {
  margin-top: 0.2rem;
  display: flex;
  justify-content: center;
}
.list {
  margin-top: 0.2rem;
  padding: 0 0.1rem;
  font-size: 0.12rem;
}
</style>